package com.rybbaby.tss.api.memberPackage;

import com.rybbaby.tss.core.utils.AppResponse;
import com.rybbaby.tss.core.web.controller.BaseController;
import com.rybbaby.tss.front.tssMemberPackage.entity.TssMemberPackage;
import com.rybbaby.tss.front.tssMemberPackage.service.ITssMemberPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "api/memberPackage", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public class MemberPackageApi extends BaseController{
    @Autowired
    private ITssMemberPackageService tssMemberPackageService;


    @CrossOrigin
    @RequestMapping(value = "getByMemberId", method = RequestMethod.POST)
    public String getUsableTotalPakcageDetailListByMemberId(TssMemberPackage tssMemberPackage) {
        String resMsg="查询成功";
        int resCode=200;
        List<Map<String, Object>> listByMemberId =null;
        try {
            String memberId = tssMemberPackage.getMemberId();
            Integer type = tssMemberPackage.getType();
            listByMemberId = this.tssMemberPackageService.getListByMemberId(memberId, type);
        } catch (Exception e) {
            resMsg="查询失败";
            resCode=500;
            e.printStackTrace();
        }
        return new AppResponse(resMsg, resCode,listByMemberId).jsonResponse(true);
    }

}
